//
//  bound_number.hpp
//  utilities
//
//  Created by Sam Jaffe on 10/22/13.
//  Copyright (c) 2013 Sam Jaffe. All rights reserved.
//

#pragma once

template <class Tp, Tp MINIMUM_VALUE, Tp MAXIMUM_VALUE>
class bound_number final {
private:
public:
    typedef Tp value_type;
    
    bound_number() = default;
    bound_number(const bound_number& other) = default;
    bound_number(bound_number&& other) = default;
    bound_number& operator=(const bound_number& other) = default;
    bound_number& operator=(bound_number&& other) = default;
    ~bound_number() = default;

    bound_number(const Tp value) :
    value(value) {
        
    }
    
    bound_number& operator --() {
        if (value > MINIMUM_VALUE) {
            --value;
        }
        return *this;
    }
    
    bound_number& operator ++() {
        if (value < MAXIMUM_VALUE) {
            ++value;
        }
        return *this;
    }
    
    bound_number operator --(int) {
        bound_number tmp = *this;
        if (value > MINIMUM_VALUE) {
            --value;
        }
        return tmp;
    }
    
    bound_number operator ++(int) {
        bound_number tmp = *this;
        if (value < MAXIMUM_VALUE) {
            ++value;
        }
        return tmp;
    }
    
    operator Tp() const {
        return value;
    }
private:
    Tp value;
};
